<?php


namespace App\service;
use Illuminate\Support\Facades\Redis;


class AddFoot
{
    public static function addFoot($user_id, $goods_id)
    {
        //只保留100条浏览记录
        $length = Redis::lLen('_user_foot' . $user_id);
        $limit = 100;
        //判断是否大于100条
        if ($length > $limit) {
            $cut = $limit - $length;
            //移除最早的浏览记录
            Redis::ltrim('_user_foot' . $user_id, $cut,$limit);
        }else{
            //把goods_id插入到列表左侧
            Redis::lpush('_user_foot' . $user_id, $goods_id);
        }
    }
}
